﻿@inject IDataCacheService _dataCacheService
@inject IHttpService _httpService


@if (_dataCacheService.ThemeSetting.IsTransparent)
{
    @if (string.IsNullOrWhiteSpace(Model?.MBgImage) == false)
    {
        <div id="web_bg" style="@($"background-image: url({Model?.MBgImage})")" class=" d-none d-sm-block"></div>
    }
    @if (string.IsNullOrWhiteSpace(Model?.SBgImage) == false)
    {
        <div id="web_bg" style="@($"background-image: url({Model?.SBgImage})")" class="d-md-none"></div>
    }
}

@code {
    UserInforViewModel Model;

    [CascadingParameter]
    private Task<AuthenticationState> authenticationStateTask { get; set; }

    protected override async Task OnInitializedAsync()
    {
        var user = await authenticationStateTask;
        if (user.User.Identity.IsAuthenticated&& Model==null)
        {
            try
            {
                string userId = userId = user.User.Claims.GetUserId();

                if (string.IsNullOrWhiteSpace(userId) == false)
                {
                    Model = await _httpService.GetAsync<UserInforViewModel>("api/space/GetUserData/" + userId);

                    StateHasChanged();
                }
            }
            catch
            {

            }
        }
    }
}
